profiler: Add profiler marks for when surfaces are mapped and unmapped
authorAlexander Larsson <alexl@redhat.com>
Wed, 12 Feb 2020 11:44:43 +0000 (12:44 +0100)
committerAlexander Larsson <alexl@redhat.com>
Wed, 12 Feb 2020 11:44:43 +0000 (12:44 +0100)
This is done on the X11 side so we can tell when the map/unmap takes
effect and how long it took since the map request.

gdk/x11/gdkdisplay-x11.c
gdk/x11/gdksurface-x11.c
gdk/x11/gdksurface-x11.h

index e13f74b822e84798ee7c0cead8d38afc6044ad29..0d442aac8f06f9b87f9227995b4868f989242560 100644 (file)
@@ -881,6 +881,9 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
             gdk_surface_freeze_updates (surface);
 
           _gdk_x11_surface_grab_check_unmap (surface, xevent->xany.serial);
+
+          if (GDK_PROFILER_IS_RUNNING)
+            gdk_profiler_add_markf (g_get_monotonic_time (), 0, "Unmapped window", "0x%lx", GDK_SURFACE_XID (surface));
         }
 
       return_val = FALSE;
@@ -902,6 +905,12 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
 
          if (toplevel)
            gdk_surface_thaw_updates (surface);
+
+          if (GDK_PROFILER_IS_RUNNING)
+            {
+              gdk_profiler_end_markf (surface_impl->map_time, "Mapped window", "0x%lx", GDK_SURFACE_XID (surface));
+              surface_impl->map_time = 0;
+            }
        }
 
       return_val = FALSE;
index a8172b0d1415c65bad5310169a9b08834cdc0e05..b9e122a91a4cf4cf647b79d90d92098017742e42 100644 (file)
@@ -1205,6 +1205,7 @@ gdk_x11_surface_show (GdkSurface *surface, gboolean already_mapped)
   GdkToplevelX11 *toplevel;
   Display *xdisplay = GDK_SURFACE_XDISPLAY (surface);
   Window xwindow = GDK_SURFACE_XID (surface);
+  GdkX11Surface *impl = GDK_X11_SURFACE (surface);
 
   if (!already_mapped)
     set_initial_hints (surface);
@@ -1217,7 +1218,13 @@ gdk_x11_surface_show (GdkSurface *surface, gboolean already_mapped)
       display_x11->user_time != 0 &&
       XSERVER_TIME_IS_LATER (display_x11->user_time, toplevel->user_time))
     gdk_x11_surface_set_user_time (surface, display_x11->user_time);
-  
+
+ if (GDK_PROFILER_IS_RUNNING)
+   {
+     if (impl->map_time == 0)
+       impl->map_time = g_get_monotonic_time ();
+   }
+
   XMapWindow (xdisplay, xwindow);
   
   /* Fullscreen on current monitor is the default, no need to apply this mode
index fe0ece1c19971f96723a4e59f671c8dba475e515..29f9cf6a6dc57d829a43a6919c90c869b929f18f 100644 (file)
@@ -78,6 +78,8 @@ struct _GdkX11Surface
 
   int abs_x;
   int abs_y;
+
+  guint64 map_time;
 };
  
 struct _GdkX11SurfaceClass